package com.yboot.starter.springdoc.core;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.tags.Tag;
import java.util.Comparator;
import java.util.List;
import org.springdoc.core.customizers.GlobalOpenApiCustomizer;
import org.springframework.util.CollectionUtils;

public class TagOrderOpenApiCustomizer implements GlobalOpenApiCustomizer {
    public TagOrderOpenApiCustomizer() {
    }

    public void customise(OpenAPI openApi) {
        List<Tag> tags = openApi.getTags();
        if (!CollectionUtils.isEmpty(tags)) {
            tags.sort(Comparator.comparing(Tag::getName));
        }
    }
}